package com.ryskoo.catering.orderaddress.repository;

import com.ryskoo.catering.orderaddress.domain.OrderAddressPO;
import com.ryskoo.framework.core.repository.BasicJPAImpl;
import com.ryskoo.framework.core.utils.ReflectHelper;
import org.hibernate.Query;
import org.springframework.stereotype.Repository;

@Repository
public class OrderAddressJPAImpl extends BasicJPAImpl<OrderAddressPO> implements IOrderAddressRepository {
    @Override
    public OrderAddressPO getAddressByOrderUuid(String orderUuid) {
        String hql = "select o" + getMultiSelect() + " from "
                + ReflectHelper.getModelClass(this.getClass()).getName()
                + " o " + getMultiModel() + " where orderUuid=:orderUuid ";

        Query q = getH4Session().createQuery(hql);
        q.setString("orderUuid", orderUuid);
        return (OrderAddressPO) q.uniqueResult();
    }
}
